using System;
using System.Collections.Generic;
using System.Text;

using Weazel.Microblaze.Simulator.Engine;

namespace Weazel.Microblaze.Simulator.Components.Microblaze.Instructions
{
    /// <summary>
    /// Write to instruction cache
    /// </summary>
    public class Wic : Instruction
    {
        public override void Set(uint address, uint value)
        {
            base.Set(address, value);

            if (ImmediateValue != 0x68)
                throw new UnknownInstructionException(value);
        }

        public Wic()
            : base("wic")
        {
        }

        public override int CycleCount
        {
            get { return 1; }
        }

        /// <summary>
        /// Write into the instruction cache tag. The register rB value is not 
        /// used. Register rA contains the instruction address. Bit 30 in rA is 
        /// the new valid bit. The WIC instruction should only be used when the 
        /// instruction cache is disabled (i.e. MSR[ICE]=0).
        /// </summary>    
        public override void Execute(MicroblazeComponent MicroblazeComponent)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override string ToString()
        {
            return string.Format("wic r{0}, r{1}",
              SourceRegisterA,
              SourceRegisterB
            );
        }
    }
}